require(['jquery', 'cookie', 'app', 'lay'], function ($) {
    require(['vue'], function (Vue) {
        layui.use(['form', 'laydate', 'upload'], function () {
            var form = layui.form;
            form.on('submit(formDemo)', function (data) {
                var da = dic.specList;
                for(var i=0;i<da.length;i++){
                    da[i].status="";
                    da[i].shop="";
                    /*if(da[i].repertory+da[i].note<0){
                        alr("库存不能为负！");
                        return false;
                    }*/
                }
                var re= playAjax("/RepertoryController/Save",{spec:da});
                alr(re.msg);
                setTimeout(function () {
                    window.reload();
                },500);
                return false;
            });
        });
        var dic = new Vue({
            el: ".vue-box"
            , data: {
                where: [],
                spec:"",
                specList:[]
            }
            , created: function () {
                var uuid  = new acquire().parameterMap['uuid'];
                var da=playAjax("ShopController/GetShop",{uuid:uuid}).data;
                this.spec=da.spec.length;
                for(var i=0;i<da.spec.length;i++){
                    da.spec[i]['note']=da.spec[i]['repertory'];
                    da.spec[i]['repertory']=0;
                }
                this.specList=da.spec;
            }
            , methods: {
                referXadmin: function () {
                    window.location.reload();
                },
            }
        });
    })
});
